<?php

namespace App\Models;

use App\Models\Business\ShiftSetting;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;

class Department extends Model
{
    use HasFactory;
    protected function serializeDate(\DateTimeInterface $date)
    {
        return $date->format('Y/m/d H:i:s');
    }
    protected $guarded = [];
    public function permissions(): BelongsToMany
    {
        return $this->belongsToMany(
            config('permission.models.permission'),
            config('permission.table_names.department_has_permissions'),
            'department_id',
            'permission_id'
        );
    }

    //
    public function department1(){
        return $this->belongsTo(Department::class,'pid','id');
    }
    //
    public function shift(){
        return $this->belongsTo(ShiftSetting::class,'shift_id');
    }

}
